<template>
  <page-layout :avatar="avatar">
    <div slot="headerContent">
      <div class="title">{{ timeFix }}，{{ nickname() }}<span class="welcome-text">，{{ welcome() }}</span></div>
    </div>
    <div slot="extra">
      <a-row class="more-info">
        <a-col :span="8">
          <a-avatar slot="avatar" src="https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png"/>
          <head-info title="待办合同" content="56" :center="false" :bordered="false"/>
        </a-col>
        <a-col :span="8">
          <head-info title="已办合同" content="24" :center="false" :bordered="false"/>
        </a-col>
        <a-col :span="8">
          <head-info title="驳回合同" content="23" :center="false"/>
        </a-col>
      </a-row>
    </div>

    <div>
      <a-row :gutter="24">
        <a-col
          style="padding: 0 12px"
          :xl="8"
          :lg="24"
          :md="24"
          :sm="24"
          :xs="24">
          <a-card title="便捷导航" style="margin-bottom: 24px" :bordered="false" :body-style="{padding: 0}">
            <div class="item-group">
              <a>
                <img src=""/>
                <span>合同中心</span>
              </a>
              <a>
                <img src=""/>
                <span>菜单设置</span>
              </a>
              <a-button size="small" type="primary" ghost icon="plus">添加</a-button>
            </div>
          </a-card>

          <a-card :loading="loading" title="动态" :bordered="false">
            <a-list>
              <a-list-item :key="index" v-for="(item, index) in activities">
                <a-list-item-meta>
                  <a-avatar slot="avatar" :src="item.user.avatar"/>
                  <div slot="title">
                    <span>{{ item.user.nickname }}</span>&nbsp;
                    在&nbsp;<a href="#">{{ item.project.name }}</a>&nbsp;
                    <span>{{ item.project.action }}</span>&nbsp;
                    <a href="#">{{ item.project.event }}</a>
                  </div>
                  <div slot="description">{{ item.time }}</div>
                </a-list-item-meta>
              </a-list-item>
            </a-list>
          </a-card>

        </a-col>

        <a-col :xl="16" :lg="24" :md="24" :sm="24" :xs="24">
          <a-card
            class="project-list"
            style="margin-bottom: 24px;"
            :bordered="false"
            title="我的待办">
            <div>

              <a-list size="large" :pagination="{showSizeChanger: true, showQuickJumper: true, pageSize: 5, total: 50}">
                <a-list-item :key="index" v-for="(item, index) in data">
                  <a-list-item-meta :description="item.description">
                    <a-avatar slot="avatar" size="large" shape="square" :src="item.avatar"/>
                    <a slot="title">{{ item.title }}</a>
                  </a-list-item-meta>
                  <div slot="actions">
                    <a>编辑</a>
                  </div>
                  <div slot="actions">
                    <a-dropdown>
                      <a-menu slot="overlay">
                        <a-menu-item><a>编辑</a></a-menu-item>
                        <a-menu-item><a>删除</a></a-menu-item>
                      </a-menu>
                      <a>更多
                        <a-icon type="down"/>
                      </a>
                    </a-dropdown>
                  </div>
                  <div class="list-content">
                    <div class="list-content-item">
                      <span>负责人</span>
                      <p>{{ item.owner }}</p>
                    </div>
                    <div class="list-content-item">
                      <span>截止时间</span>
                      <p>{{ item.startAt }}</p>
                    </div>
                  </div>
                </a-list-item>
              </a-list>

            </div>
          </a-card>


        </a-col>

      </a-row>
    </div>
  </page-layout>
</template>

<script>
  import {timeFix} from "@/utils/util"
  import {mapGetters} from "vuex"
  import PageLayout from '@/components/page/PageLayout'
  import HeadInfo from '@/components/tools/HeadInfo'
  import Radar from '@/components/chart/Radar'
  import {getRoleList, getServiceList} from "@/api/manage"

  const DataSet = require('@antv/data-set')
  const data = []
  data.push({
    title: 'Alipay',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
    description: '深圳闻泰通讯科技合作计划通过方案签订合同',
    owner: '付晓晓',
    startAt: '2018-07-26',
    progress: {
      value: 90
    }
  })
  data.push({
    title: 'Angular',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
    description: '深圳闻泰通讯科技合作计划通过方案签订合同',
    owner: '曲丽丽',
    startAt: '2018-07-26',
    progress: {
      value: 54
    }
  })
  data.push({
    title: 'Ant Design',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png',
    description: '深圳闻泰通讯科技合作计划通过方案签订合同',
    owner: '林东东',
    startAt: '2018-07-26',
    progress: {
      value: 66
    }
  })
  data.push({
    title: 'Ant Design Pro',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png',
    description: '深圳闻泰通讯科技合作计划通过方案签订合同',
    owner: '周星星',
    startAt: '2018-07-26',
    progress: {
      value: 30
    }
  })
  data.push({
    title: 'Bootstrap',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png',
    description: '深圳闻泰通讯科技合作计划通过方案签订合同',
    owner: '吴加好',
    startAt: '2018-07-26',
    progress: {
      status: 'exception',
      value: 100
    }
  })
  export default {
    name: "Workplace",
    components: {
      PageLayout,
      HeadInfo,
      Radar
    },
    data() {
      return {
        timeFix: timeFix(),
        avatar: '',
        user: {},
        loading: false,
        radarLoading: true,
        data,
        axis1Opts: {
          dataKey: 'item',
          line: null,
          tickLine: null,
          grid: {
            lineStyle: {
              lineDash: null
            },
            hideFirstLine: false
          }
        },
        axis2Opts: {
          dataKey: 'score',
          line: null,
          tickLine: null,
          grid: {
            type: 'polygon',
            lineStyle: {
              lineDash: null
            }
          }
        },
        scale: [{
          dataKey: 'score',
          min: 0,
          max: 80
        }],
        radarData: []
      }
    },
    computed: {
      userInfo() {
        return this.$store.getters.userInfo
      }
    },
    created() {
      this.user = this.userInfo
      this.avatar = window._CONFIG['imgDomainURL'] + "/" + this.userInfo.avatar
      // console.log('this.avatar :'+ this.avatar)
    },
    mounted() {
      this.getProjects()
      this.getActivity()
      this.getTeams()
      this.initRadar()
    },
    methods: {
      ...mapGetters(["nickname", "welcome"]),
      getProjects() {
        // this.$http.get('/list/search/projects')
        //   .then(res => {
        //     this.projects = res.result && res.result.data
        //     this.loading = false
        //   })
      },
      getActivity() {
        // this.$http.get('/workplace/activity')
        //   .then(res => {
        //     this.activities = res.result
        //   })
      },
      getTeams() {
        // this.$http.get('/workplace/teams')
        //   .then(res => {
        //     this.teams = res.result
        //   })
      },
      initRadar() {
        // this.radarLoading = true
        //
        // this.$http.get('/chart/radar')
        //   .then(res => {
        //     const dv = new DataSet.View().source(res.result)
        //     dv.transform({
        //       type: 'fold',
        //       fields: ['个人', '团队', '部门'],
        //       key: 'user',
        //       value: 'score'
        //     })
        //
        //     this.radarData = dv.rows
        //     this.radarLoading = false
        //   })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .main {
    .title {
      line-height: 75px !important;
      margin-bottom: 0 !important;
    }

    .head-info {
      padding-top: 10px !important;
    }

    .ant-list-item-content {
      justify-content: flex-start !important;
    }
  }

  .project-list {
    .card-title {
      font-size: 0;

      a {
        color: rgba(0, 0, 0, 0.85);
        margin-left: 12px;
        line-height: 24px;
        height: 24px;
        display: inline-block;
        vertical-align: top;
        font-size: 14px;

        &:hover {
          color: #1890ff;
        }
      }
    }

    .card-description {
      color: rgba(0, 0, 0, 0.45);
      height: 44px;
      line-height: 22px;
      overflow: hidden;
    }

    .project-item {
      display: flex;
      margin-top: 8px;
      overflow: hidden;
      font-size: 12px;
      height: 20px;
      line-height: 20px;

      a {
        color: rgba(0, 0, 0, 0.45);
        display: inline-block;
        flex: 1 1 0;

        &:hover {
          color: #1890ff;
        }
      }

      .datetime {
        color: rgba(0, 0, 0, 0.25);
        flex: 0 0 auto;
        float: right;
      }
    }

    .ant-card-meta-description {
      color: rgba(0, 0, 0, 0.45);
      height: 44px;
      line-height: 22px;
      overflow: hidden;
    }
  }

  .item-group {
    padding: 20px 0 8px 24px;
    font-size: 0;

    a {
      color: rgba(0, 0, 0, 0.65);
      display: inline-block;
      font-size: 14px;
      margin-bottom: 13px;
      width: 25%;
    }
  }

  .members {
    a {
      display: block;
      margin: 12px 0;
      line-height: 24px;
      height: 24px;

      .member {
        font-size: 14px;
        color: rgba(0, 0, 0, .65);
        line-height: 24px;
        max-width: 100px;
        vertical-align: top;
        margin-left: 12px;
        transition: all 0.3s;
        display: inline-block;
      }

      &:hover {
        span {
          color: #1890ff;
        }
      }
    }
  }

  .mobile {

    .project-list {

      .project-card-grid {
        width: 100%;
      }
    }

    .more-info {
      border: 0;
      padding-top: 16px;
      margin: 16px 0 16px;
    }

    .headerContent .title .welcome-text {
      display: none;
    }
  }

  .ant-avatar-lg {
    width: 48px;
    height: 48px;
    line-height: 48px;
  }

  .list-content-item {
    color: rgba(0, 0, 0, .45);
    display: inline-block;
    vertical-align: middle;
    font-size: 14px;
    margin-left: 40px;

    span {
      line-height: 20px;
    }

    p {
      margin-top: 4px;
      margin-bottom: 0;
      line-height: 22px;
    }
  }

</style>